var t = require("../../../@babel/runtime/helpers/interopRequireDefault").default,
  a = require("../../../utils/http"),
  e = t(require("../../../components/u-charts/u-charts.min")),
  r = t(require("../../../utils/util")),
  d = new a.HTTP,
  n = {};
Page({
  data: {
    cWidth: 750,
    cHeight: 600,
    pixelRatio: 2,
    type: "",
    num: 1,
    unmonth: !0,
    slideWidth: "",
    slideLeft: 0,
    totalLength: "",
    slideShow: !1,
    slideRatio: "",
    dataList: [{
      text: "1"
    }, {
      text: "2"
    }, {
      text: "3"
    }, {
      text: "4"
    }, {
      text: "5"
    }, {
      text: "6"
    }, {
      text: "7"
    }, {
      text: "8"
    }, {
      text: "9"
    }, {
      text: "10"
    }, {
      text: "11"
    }, {
      text: "12"
    }],
    list: r.default.formatDates(new Date),
    funnel: !1,
    bm: 1
  },
  changeOil: function (t) {
    var a = this;
    if (wx.showLoading({
        title: "加载中"
      }), setTimeout((function () {
        wx.hideLoading()
      }), 200), 2 == t.target.dataset.num ? a.setData({
        unmonth: !1
      }) : a.setData({
        unmonth: !0
      }), a.setData({
        num: t.target.dataset.num,
        bm: 1
      }), 1 == a.data.unmonth)
      this.getServerData(), d.request({
        url: "https://www.qlsyyun.com:3000/trader/board",
        data: {
          arr: 1
        }
      }).then((function (t) {
        a.setData({
          client: t.data[0],
          currentItem: 0
        })
      }));
    else {
      var e = wx.getSystemInfoSync();
      this.setData({
          windowWidth: e.windowWidth
        }),
        this.getRatio(),
        d.request({
          url: "https://www.qlsyyun.com:3000/trader/board",
          data: {
            arr: 6,
            yf: a.data.list
          }
        }).then((function (t) {
          0 == t.data.length ? a.setData({
            client: {
              jda: 0,
              jdb: 0,
              jdc: 0,
              jdd: 0
            }
          }) : a.setData({
            client: t.data[0]
          })
        }))
    }
  },
  getRatio: function () {
    if (this.data.dataList.length < 4)
      this.setData({
        slideShow: !1
      });
    else {
      var t = 173 * this.data.dataList.length,
        a = 80 / t * (750 / this.data.windowWidth),
        e = 750 / t * 160;
      this.setData({
        slideWidth: e / 2,
        totalLength: t,
        slideShow: !0,
        slideRatio: a
      })
    }
  },
  getleft: function (t) {
    this.setData({
      slideLeft: t.detail.scrollLeft * this.data.slideRatio
    })
  },
  navlist: function (t) {
    var a = this,
      e = t.currentTarget.dataset.title;
    a.setData({
        list: e
      }),
      "" == a.data.type || "公司" == a.data.type ? d.request({
        url: "https://www.qlsyyun.com:3000/trader/board",
        data: {
          arr: 6,
          yf: e
        }
      }).then((function (t) {
        0 == t.data.length ? a.setData({
          client: {
            jda: 0,
            jdb: 0,
            jdc: 0,
            jdd: 0
          }
        }) : a.setData({
          client: t.data[0]
        })
      })) : d.request({
        url: "https://www.qlsyyun.com:3000/trader/board",
        data: {
          arr: 7,
          bm: a.data.type,
          yf: e
        }
      }).then((function (t) {
        0 == t.data.length ? a.setData({
          client: {
            jda: 0,
            jdb: 0,
            jdc: 0,
            jdd: 0
          }
        }) : a.setData({
          client: t.data[0]
        })
      }))
  },
  navigateToPage: function (t) {
    var a = this,
      e = this,
      r = t.target.dataset.type;
    e.setData({
        type: r.bm,
        currentItem: r.id
      }),
      1 == e.data.unmonth ? "公司" != r.bm ? (e.setData({
        bm: 2
      }), d.request({
        url: "https://www.qlsyyun.com:3000/trader/board",
        data: {
          arr: 3,
          bm: r.bm
        }
      }).then((function (t) {
        e.setData({
          client: t.data[0]
        })
      })), this.getServerData()) : (d.request({
        url: "https://www.qlsyyun.com:3000/trader/board",
        data: {
          arr: 1
        }
      }).then((function (t) {
        e.setData({
          client: t.data[0]
        })
      })), d.request({
        url: "https://www.qlsyyun.com:3000/trader/board",
        data: {
          arr: 4
        }
      }).then((function (t) {
        e.setData({
            hopper: t.data[0],
            bm: 1
          }),
          a.getServerData()
      }))) : (console.log(222), "公司" != r.bm ? d.request({
        url: "https://www.qlsyyun.com:3000/trader/board",
        data: {
          arr: 7,
          bm: e.data.type,
          yf: e.data.list
        }
      }).then((function (t) {
        0 == t.data.length ? e.setData({
          client: {
            jda: 0,
            jdb: 0,
            jdc: 0,
            jdd: 0
          }
        }) : e.setData({
          client: t.data[0]
        })
      })) : d.request({
        url: "https://www.qlsyyun.com:3000/trader/board",
        data: {
          arr: 6,
          yf: e.data.list
        }
      }).then((function (t) {
        0 == t.data.length ? e.setData({
          client: {
            jda: 0,
            jdb: 0,
            jdc: 0,
            jdd: 0
          }
        }) : e.setData({
          client: t.data[0]
        })
      })))
  },
  onReady: function () {
    var t = 1 * wx.getSystemInfoSync().windowWidth,
      a = 500 / 750 * wx.getSystemInfoSync().windowWidth,
      e = wx.getSystemInfoSync().pixelRatio;
    this.setData({
        cWidth: t,
        cHeight: a,
        pixelRatio: e
      }),
      this.getServerData()
  },
  getServerData: function () {
    var t = this,
      a = this;
    1 == a.data.bm ? d.request({
      url: "https://www.qlsyyun.com:3000/trader/board",
      data: {
        arr: 4
      }
    }).then((function (e) {
      a.setData({
        hopper: e.data[0]
      });
      var r = {
        series: [{
          data: [{
            name: "有效客户",
            value: a.data.hopper.bbkh,
            labelText: a.data.hopper.bbkh
          }, {
            name: "初步接触",
            value: a.data.hopper.cbkh,
            labelText: a.data.hopper.cbkh
          }, {
            name: "持续跟进",
            value: a.data.hopper.cxkh,
            labelText: a.data.hopper.cxkh
          }, {
            name: "核名办证",
            value: a.data.hopper.hmkh,
            labelText: a.data.hopper.hmkh
          }, {
            name: "产税",
            value: a.data.hopper.cskh,
            labelText: a.data.hopper.cskh
          }]
        }]
      };
      t.drawCharts("SXHyIJPntMlUPAmpQIBiHCeHlVHuEudD", r)
    })) : d.request({
      url: "https://www.qlsyyun.com:3000/trader/board",
      data: {
        arr: 5,
        bm: a.data.type
      }
    }).then((function (e) {
      a.setData({
        hopper: e.data[0]
      });
      var r = {
        series: [{
          data: [{
            name: "有效客户",
            value: a.data.hopper.bbkh,
            labelText: a.data.hopper.bbkh
          }, {
            name: "初步接触",
            value: a.data.hopper.cbkh,
            labelText: a.data.hopper.cbkh
          }, {
            name: "持续跟进",
            value: a.data.hopper.cxkh,
            labelText: a.data.hopper.cxkh
          }, {
            name: "核名办证",
            value: a.data.hopper.hmkh,
            labelText: a.data.hopper.hmkh
          }, {
            name: "产税",
            value: a.data.hopper.cskh,
            labelText: a.data.hopper.cskh
          }]
        }]
      };
      t.drawCharts("SXHyIJPntMlUPAmpQIBiHCeHlVHuEudD", r)
    }))
  },
  drawCharts: function (t, a) {
    var r = this;
    wx.createSelectorQuery().in(this).select("#" + t).fields({
      node: !0,
      size: !0
    }).exec((function (d) {
      if (d[0]) {
        var i = d[0].node,
          s = i.getContext("2d");
        i.width = d[0].width * r.data.pixelRatio,
          i.height = d[0].height * r.data.pixelRatio,
          n[t] = new e.default({
            type: "funnel",
            context: s,
            width: r.data.cWidth * r.data.pixelRatio,
            height: r.data.cHeight * r.data.pixelRatio,
            series: a.series,
            pixelRatio: r.data.pixelRatio,
            animation: !0,
            background: "#FFFFFF",
            color: ["#D46973", "#EACE6D", "#6DBFF0", "#57A968", "#678AC0"],
            legend: {
              position: "bottom",
              float: "bottom",
              lineHeight: "20"
            },
            extra: {
              funnel: {
                borderWidth: 1
              }
            }
          })
      } else
        console.error("[uCharts]: 未获取到 context")
    }))
  },
  tap: function (t) {
    n[t.target.id].touchLegend(t),
      n[t.target.id].showToolTip(t)
  },
  onLoad: function () {
    var t = this;
    d.request({
        url: "https://www.qlsyyun.com:3000/trader/board",
        data: {
          arr: 4
        }
      }).then((function (a) {
        t.setData({
          hopper: a.data[0]
        })
      })),
      d.request({
        url: "https://www.qlsyyun.com:3000/trader/board",
        data: {
          arr: 1
        }
      }).then((function (a) {
        t.setData({
          client: a.data[0],
          currentItem: 0
        })
      })),
      d.request({
        url: "https://www.qlsyyun.com:3000/trader/board",
        data: {
          arr: 2
        }
      }).then((function (a) {
        var e = a.data;
        e.unshift({
            bm: "公司",
            id: 0
          }),
          t.setData({
            taga: e
          })
      }))
  }
});